<?php
 
$response = array();
 
if (isset($_POST['reg_id']) && isset($_POST['pnum']) ) {
 
    $reg_id = $_POST['reg_id'];
    $pnum = $_POST['pnum'];
	echo $reg_id,$pnum;
 
    $connect = mysql_connect("127.0.0.1","root","apmsetup") or die("SQL server에 연결할 수 없습니다."); 
	mysql_selectdb("lhu114") or die("Unable to select database : " . mysql_error()); //DB 선택

    $result = mysql_query("INSERT INTO gcm_table(reg_id, phone_num) VALUES('$reg_id', '$pnum');");
 

    if ($result) {
        // successfully inserted into database
        $response["success"] = 1;
        $response["message"] = "Product successfully created.";
 
        echo json_encode($response);
    } else {
        // failed to insert row
        $response["success"] = 0;
        $response["message"] = "Oops! An error occurred.";
 
        echo json_encode($response);
    }
} else {
    // required field is missing
    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";
 
    echo json_encode($response);
}
?>